package com.woniuxy.controller;

import com.sun.org.apache.xpath.internal.operations.Mod;
import com.woniuxy.entity.UserManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Author: 马宇航
 * @Todo: 登录请求
 * @DateTime: 22/03/30/0030 下午 3:19
 * @Component: 成都蜗牛学苑
 **/
@Controller
public class LoginContoller {
    @RequestMapping("/login")
    public ModelAndView login(String username, @RequestParam("pass") String password, int money){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username",username);
        modelAndView.addObject("password",password);
        modelAndView.addObject("money",money);
        modelAndView.setViewName("/WEB-INF/jsp/success.jsp");
        return modelAndView;
    }
    @RequestMapping("/passArray")
    public ModelAndView passArray(String username,String[] hobby){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username",username);

        modelAndView.addObject("msg", Arrays.toString(hobby));
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }
    @RequestMapping("/passList")
    public ModelAndView passList(String username, @RequestParam List<String> hobby){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username",username);
        modelAndView.addObject("msg", hobby);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }
    @RequestMapping("/passMap")
    public ModelAndView passMap(@RequestParam Map<String,Object> info,@RequestParam List<String> hobby){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", info+","+hobby);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }
    @RequestMapping("/passObject")
    public ModelAndView passObject(UserManager userManager){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", userManager);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }
}
